<?php
//删除帖子
define('IN_TG',true);
define('IN_JS',true);
define('SCRIPT',true);
session_start();
require('includes/common.inc.php');
//删除处理
if(isset($_GET['id']))
{
    $tgid = intval($_GET['id']);
    $sql = "select tg_id from tg_article where tg_id = $tgid and tg_username='{$_SESSION['username']}' limit 1";
    $res1 = _fetch_array($sql);
    $arr=array();
    //判断帖子存在
    if(is_array($res1))
    {
        //删除帖子的回复内容
        $sql="delete from tg_article where tg_reid = $tgid";
        //删除帖子
        $reres = _query($sql);
        $sql = "delete from tg_article where tg_id = $tgid";
        $reres = _query($sql);
        _location("删除成功", 'index.php');
    }
    else
    {
        _alert_back("你没有权限删除帖子");
    }
}
else
{
    _alert_back("请不要非法操作");
}
?>